#include <stdio.h>
#include <wiringPi.h>
#include <softPwm.h>

#define LED 5

int main(int argc, char *argv[])
{
    int i = 0;
    if(wiringPiSetup() == -1)		//初始化必须写在最前边
	{
        printf("setup wiringPi failed !");
        return 1;
    }
	
    printf("Hello World!\n");
    softPwmCreate(LED, 0, 100);		//设置GPIO.5为PWM模式
    while(1)                        //进入主逻辑循环
    {
        i += 2;
        if(i > 100) i = 0;
        softPwmWrite(LED, i);		//GPIO.5输出PWM值
        delay(100);					//延时100毫秒
    }
    return 0;
}

